package com.haoze.nurseapp.dao;

import com.haoze.common.mapper.MyMapper;
import com.haoze.common.model.TaskExecuteBatchEntity;
import com.haoze.nurseapp.dto.task.TaskExecuteDetailDTO;
import com.haoze.nurseapp.model.TaskExecuteDetailEntity;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface TaskExecuteDetailMapper extends MyMapper<TaskExecuteDetailEntity> {

    List<TaskExecuteBatchEntity> queryExecuteDetail(@Param("qrCodes") List<String> qrCodes);

    TaskExecuteBatchEntity queryInfoByBarCode(String barCode);

    /**
     * 获取静配中心有qrCode和barCode且状态为0没有下一节点的数据
     * @param nodeId
     * @return
     */
    List<TaskExecuteBatchEntity> queryNoNextNode(String nodeId);

    /**
     * 根据传入的二维码编码查询流程明细数据以判断编码是否为qrCode
     * 已废弃，请使用queryTaskExecuteDetailInfo
     * @param qrCode
     * @return
     */
    @Deprecated
    TaskExecuteBatchEntity queryTaskExecuteDetail(@Param("qrCode") String qrCode);



    /**
     * 根据传入的二维码编码查询流程明细数据以判断编码是否为qrCode
     * @param qrCode
     * @return
     */
    TaskExecuteDetailDTO  queryTaskExecuteDetailInfo(@Param("qrCode") String qrCode);


    /**
     * 根据当前流程明细查询当前节点，判断是否在输液中心节点
     * @param qrCode
     * @return
     */
    String queryNodeId(String qrCode);

    /**
     * 根据当前流程明细查询当前节点，判断是否在输液中心节点
     * @param qrCode
     * @return
     */
    String queryInfusionNodeId(@Param("qrCode") String qrCode, @Param("nodeId") String nodeId);

    /**
     * 将输液中心传递的qrCode与入院号匹配，查询是否存在当前未执行数据
     * @param qrCode
     * @param inpatNum
     * @param nodeId
     * @return
     */
    TaskExecuteDetailEntity isExistTaskExecuteDetail(@Param("qrCode") String qrCode,@Param("inpatNum") String inpatNum,@Param("nodeId") String nodeId);

    int updateByEmrFileId(String emrFileId);

    /**
     * 更新明细表数据
     * @param barCode
     * @param taskBatchId
     */
    void updateByTaskExecuteId(@Param("barCode") String barCode,@Param("taskBatchId") String taskBatchId);

    /**
     * 获取所有在输液中心且输液未完成的任务
     * @param nodeId
     * @return
     */
    List<TaskExecuteBatchEntity> queryDataEntities(@Param("nodeId") String nodeId);

    String queryNodeIdByTaskNodeId(@Param("taskNodeId") String taskNodeId);

    List<TaskExecuteDetailEntity> queryByEntity(TaskExecuteDetailEntity nextDetailEntityParam);

    void updateEmrFileIdById(@Param("taskExecuteDetailId") String taskExecuteDetailId, @Param("emrFileId") String emrFileId);
}
